#include <iostream>
#include <ostream>
using namespace std;
int main() {
    int n = 0;
    cin >> n;
    int i = 0;
    int count = 0;
    for (i = 7; i <= n; ++i) {
        if (i % 7 == 0) {
            ++count;
            continue;
        }
        int oldval = i;
        while (oldval) {
            if (oldval % 10 == 7) {
                ++count;
                break;
            }
            oldval /= 10;
        }
    }
    cout << count << endl;
}